
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class UmsUserRoleServiceImpl implements UmsUserRoleService  {

    @Resource
    private UmsUserRoleMapper umsUserRoleMapper;

    /**
     * 获取 UmsUserRole 分页列表
     */
    @Transactional
    public IPage getUmsUserRolePagination( PaginationVo paginationVo, UmsUserRoleQuery umsUserRoleQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<UmsUserRoleEntity> lqs = new LambdaQueryWrapper();
        umsUserRoleMapper.selectPage(page, lqs);

        List<UmsUserRoleEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 UmsUserRole 所有数据
     *
    */
    @Transactional
    public List<UmsUserRoleEntity> getUmsUserRoleAllList( UmsUserRoleQuery umsUserRoleQuery ) throws Exception {

        LambdaQueryWrapper<UmsUserRoleEntity> lqs = new LambdaQueryWrapper();
        List<UmsUserRoleEntity> list = umsUserRoleMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 UmsUserRole 详情
    */
    @Transactional
    public UmsUserRoleEntity getUmsUserRoleDetail( Long id) throws Exception {

        UmsUserRoleEntity umsUserRole = umsUserRoleMapper.selectById(id);
        return umsUserRole;
    }


    /**
     * 新增 UmsUserRole
     * */
    @Transactional
    public void addUmsUserRole(UmsUserRoleVo umsUserRoleVo) throws Exception {

        UmsUserRoleEntity umsUserRole = new UmsUserRoleEntity();
        ReflectionCopy.copyProperties( umsUserRole, umsUserRoleVo );
        umsUserRoleMapper.insert(umsUserRole);
        return;
    }


    /**
     * 更新 UmsUserRole
     * */
    @Transactional
    public void updateUmsUserRole( UmsUserRoleVo umsUserRoleVo) throws Exception {

        if( umsUserRoleVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        UmsUserRoleEntity umsUserRole = new UmsUserRoleEntity();
        ReflectionCopy.copyProperties( umsUserRole, umsUserRoleVo );
        umsUserRoleMapper.updateById(umsUserRole);
        return;
    }

    /**
     * 删除 UmsUserRole
     * */
    @Transactional
    public void batchRemoveUmsUserRole( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        umsUserRoleMapper.deleteBatchIds(ids);
    }

}

      